#ifndef JSONRPCERRORCODE_H
#define JSONRPCERRORCODE_H

#include <string>

namespace RpcError {
    static constexpr int PARSE_ERROR = -32700;
    static constexpr int INVALID_REQUEST = -32600;
    static constexpr int METHOD_NOT_FOUND = -32601;
    static constexpr int INVALID_PARAMS = -32602;
    static constexpr int INTERNAL_ERROR = -32603;
    static constexpr int SERVER_ERROR = -32000;

    static const std::string Code2Msg(const int code)
    {
        switch (code) {
            case PARSE_ERROR:
                return "Parse error, server receives invalid JSON";
            case INVALID_REQUEST:
                return "Invalid request. The JSON sent is not a valid request object";
            case METHOD_NOT_FOUND:
                return "Method not found, method does not exist or invalid";
            case INVALID_PARAMS:
                return "Invalid argument. The supplied argument is invalid";
            case INTERNAL_ERROR:
                return "Internal error, JSON-RPC internal error";
            default:
                // For custom error codes, provide a generic message
                if (code >= -32099 && code <= -32000) {
                    return "Internal server error";
                }
                return "Unknown error";
        }
    }
}


#endif // JSONRPCERRORCODE_H
